<template>
	<view>
		<u-table style="margin-top: 10rpx;">
			<u-tr class="u-tr">
				<u-th class="u-th">巷道号</u-th>
				<u-th class="u-th">总容量</u-th>
				<u-th class="u-th">已用托数</u-th>
				<u-th class="u-th">任务数</u-th>
				<u-th class="u-th">操作</u-th>
			</u-tr>
			<u-tr class="u-tr" v-for="(item,index) in dataList" :key="index" >
				<u-td class="u-td">{{item.roadWayCode }}</u-td>
				<u-th class="u-th">{{item.allNum }}</u-th>
				<u-td class="u-td">{{item.seq}}</u-td>
				<u-td class="u-td"><text :style="{ color: item.flag }">{{item.taskCnt}}</text></u-td>
				<u-td class="u-td"><text style="color: red;" @click="receive(item)">清空</text></u-td>
			</u-tr>
		</u-table>
		<view>
			<u-toast ref="uToast" />
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
					dataList: [],
					laneNumber: "", //行道号
					state: "", //状态
			}
		},
		onShow() {
			this.refresh()
		},
		
		onPullDownRefresh() {
			this.refresh()
			uni.stopPullDownRefresh()
		},
		methods: {
			refresh() {
					this.$http.post('/rest/hikAgvTaskController/RoadWayListAllJL', {}, {
						params: {
							laneNumber: this.keyword,
						},
						header: {
							'Authorization': uni.getStorageSync('token'),
						}
					}).then(res => {
						uni.hideLoading()
						if (res.statusCode == 200) {
							this.dataList = res.data
							this.keyword = ""
						} else {
							this.$refs.uToast.show({
								title: res.data.message,
								type: 'error'
							})
							setTimeout(() => {
								this.$Router.back()
							}, 1500)
						}
					})
			},
			
			receive(item){
				uni.showModal({
					title:'确认清空通道吗?',
					success: (res) => {
						if (res.confirm) {
							this.$http.post('/rest/hikAgvTaskController/clearJL',{
							},{
								params: {
									roadWayCode: item.roadWayCode,
								},
								header: {
									'Authorization' :uni.getStorageSync('token'),
								}
							}).then(res => {
								if(res.data.code == 200) {
									this.$refs.uToast.show({
										title: '清空成功',
										type: 'success'
									})
									this.refresh();
								} else {
									this.$refs.uToast.show({
										title: res.data.message,
										type: 'error'
									})
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
		}
	}
</script>
<style lang="scss">
	page {
		background-color: #ffffff;
	}
	
	.wrap {
		padding: 30rpx;
	}
</style>